package com.googlecode.yoohoo.io.socket;

import org.apache.mina.common.ByteBuffer;
import org.apache.mina.common.IoSession;
import org.apache.mina.filter.codec.ProtocolEncoderAdapter;
import org.apache.mina.filter.codec.ProtocolEncoderOutput;

import com.googlecode.yoohoo.utils.Constants;

public class XmppEncoder extends ProtocolEncoderAdapter {
	@Override
	public void encode(IoSession session, Object message,
			ProtocolEncoderOutput out) throws Exception {
		if (message instanceof String) {
			out.write(ByteBuffer.wrap(((String)message).getBytes(Constants.DEFAULT_CHARSET)));
		}
	}

}
